﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;

namespace Communication.Tcp
{
    /// <summary>
    /// Represents IOCP Task
    /// </summary>
    class Task
    {
        #region Ctor
        public Task(WorkType type, TcpClient client, TaskFactory factory)
        {
            this.m_client = client;
            this.m_type = type;
            this.m_creator = factory;
        }
        #endregion

        #region Methods

        /// <summary>
        /// Marks task as done.
        /// </summary>
        public void Done()
        {
            this.m_creator.RemoveTask(this);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals(Object obj)
        {
            Task task_obj = obj as Task;
            if (task_obj == null) return false;
            return (task_obj.m_type == this.m_type && task_obj.m_client == this.m_client);
        }
        #endregion

        #region Properties
        public WorkType Type 
        {
            get { return m_type; }
        }
        public TcpClient Client
        {
            get { return m_client; }
        }
        #endregion

        #region Fields
        private TcpClient m_client;
        private WorkType m_type;
        private TaskFactory m_creator;
        #endregion

    }
}
